home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / cstex / disk2 / texinfo.lzh / INPUTS / TEXINFO / TEXINFO.TEX < prev    next >
Encoding:
Text File  |  1990-08-06  |  78.7 KB  |  2,458 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %!% Patched Version: - Replaced CTRL_Z by `^^Z' etc.
  4. %!%                  - Changed some fonts
  5. %!%                  - Removed the horizontal rule from the title page
  6.  
  7. %   Copyright (C) 1985, 1986, 1988, 1990 Free Software Foundation, Inc.
  8.  
  9. %This texinfo.tex file is free software; you can redistribute it and/or
  10. %modify it under the terms of the GNU General Public License as
  11. %published by the Free Software Foundation; either version 1, or (at
  12. %your option) any later version.
  13.  
  14. %This texinfo.tex file is distributed in the hope that it will be
  15. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  16. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. %General Public License for more details.
  18.  
  19. %You should have received a copy of the GNU General Public License
  20. %along with this texinfo.tex file; see the file COPYING.  If not, write
  21. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  22. %USA.
  23.  
  24.  
  25. %In other words, you are welcome to use, share and improve this program.
  26. %You are forbidden to forbid anyone else to use, share and improve
  27. %what you give them.   Help stamp out software-hoarding!
  28.  
  29. \def\texinfoversion{2.8}
  30. \message{Loading texinfo package [Version \texinfoversion]:}
  31. \message{}
  32.  
  33. % Print the version number if in a .fmt file.
  34. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  35.  
  36. % Save some parts of plain tex whose names we will redefine.
  37.  
  38. \let\ptexlbrace=\{
  39. \let\ptexrbrace=\}
  40. \let\ptexdot=\.
  41. \let\ptexstar=\*
  42. \let\ptexend=\end
  43. \let\ptexbullet=\bullet
  44. \let\ptexb=\b
  45. \let\ptexc=\c
  46. \let\ptexi=\i
  47. \let\ptext=\t
  48. \let\ptexl=\l
  49. \let\ptexL=\L
  50.  
  51. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  52.  
  53. \message{Basics,}
  54. \chardef\other=12
  55.  
  56. \hyphenation{ap-pen-dix}
  57. \hyphenation{mini-buf-fer mini-buf-fers}
  58. \hyphenation{eshell}
  59.  
  60. % Margin to add to right of even pages, to left of odd pages.
  61. \newdimen \bindingoffset  \bindingoffset=0pt
  62. \newdimen \normaloffset   \normaloffset=\hoffset
  63. \newdimen\pagewidth \newdimen\pageheight
  64. \pagewidth=\hsize \pageheight=\vsize
  65.  
  66. %---------------------Begin change-----------------------
  67. %
  68. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  69. %
  70. \newdimen\cornerlong \newdimen\cornerthick
  71. \newdimen \topandbottommargin
  72. \newdimen \outerhsize \newdimen \outervsize
  73. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  74. \outerhsize=7in
  75. \outervsize=9.5in
  76. \topandbottommargin=.75in
  77. %
  78. %---------------------End change-----------------------
  79.  
  80. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  81. % does insertions itself, but you have to call it yourself.
  82. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  83. \def\onepageout#1{\hoffset=\normaloffset
  84. \ifodd\pageno  \advance\hoffset by \bindingoffset
  85. \else \advance\hoffset by -\bindingoffset\fi
  86. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  87. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  88. {\let\hsize=\pagewidth \makefootline}}}%
  89. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  90.  
  91.  
  92. % Here is a modification of the main output routine for Near East Publications
  93. % This provides right-angle cropmarks at all four corners.
  94. % The contents of the page are centerlined into the cropmarks,
  95. % and any desired binding offset is added as an \hskip on either
  96. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  97. %
  98. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  99.          \shipout
  100.          \vbox to \outervsize{\hsize=\outerhsize
  101.                  \vbox{\line{\ewtop\hfill\ewtop}}
  102.                  \nointerlineskip
  103.                  \line{\vbox{\moveleft\cornerthick\nstop}
  104.                        \hfill
  105.                        \vbox{\moveright\cornerthick\nstop}}
  106.                  \vskip \topandbottommargin
  107.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  108.             \vbox{
  109.             {\let\hsize=\pagewidth \makeheadline}
  110.             \pagebody{#1}
  111.             {\let\hsize=\pagewidth \makefootline}}
  112.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  113.          \vskip \topandbottommargin plus1fill minus1fill
  114.                  \boxmaxdepth\cornerthick
  115.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  116.                        \hfill
  117.                        \vbox{\moveright\cornerthick\nsbot}}
  118.                  \nointerlineskip
  119.                  \vbox{\line{\ewbot\hfill\ewbot}}
  120.     }
  121.   \advancepageno 
  122.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  123. %
  124. % Do @cropmarks to get crop marks
  125. \def\cropmarks{\let\onepageout=\croppageout }
  126.  
  127. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  128. {\catcode`\@ =11
  129. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  130. \dimen@=\dp#1 \unvbox#1
  131. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  132. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  133. }
  134.  
  135. %
  136. % Here are the rules for the cropmarks.  Note that they are
  137. % offset so that the space between them is truly \outerhsize or \outervsize
  138. % (P. A. MacKay, 12 November, 1986)
  139. %
  140. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  141. \def\nstop{\vbox
  142.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  143. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  144. \def\nsbot{\vbox
  145.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  146.  
  147. % Parse an argument, then pass it to #1.
  148. % The argument can be delimited with [...] or with "..." or braces
  149. % or it can be a whole line.
  150. % #1 should be a macro which expects
  151. % an ordinary undelimited TeX argument.
  152.  
  153. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
  154.  
  155. \def\parseargx{%
  156. \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
  157. \aftergroup \parseargline %
  158. \fi \endgroup}
  159.  
  160. {\obeyspaces %
  161. \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
  162.  
  163. \gdef\obeyedspace{\ }
  164.  
  165. \def\parseargline{\begingroup \obeylines \parsearglinex}
  166. {\obeylines %
  167. \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
  168.  
  169. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  170.  
  171. %% These are used to keep @begin/@end levels from running away
  172. %% Call \inENV within environments (after a \begingroup)
  173. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  174. \def\ENVcheck{%
  175. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  176. \endgroup\fi} % This is not perfect, but it should reduce lossage
  177.  
  178. % @begin foo  is the same as @foo, for now.
  179. \newhelp\EMsimple{Type <Return> to continue}
  180.  
  181. \outer\def\begin{\parsearg\beginxxx}
  182.  
  183. \def\beginxxx #1{%
  184. \expandafter\ifx\csname #1\endcsname\relax
  185. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  186. \csname #1\endcsname\fi}
  187.  
  188. %% @end foo executes the definition of \Efoo.
  189. %% foo can be delimited by doublequotes or brackets.
  190.  
  191. \def\end{\parsearg\endxxx}
  192.  
  193. \def\endxxx #1{%
  194. \expandafter\ifx\csname E#1\endcsname\relax
  195. \expandafter\ifx\csname #1\endcsname\relax
  196. \errmessage{Undefined command @end #1}\else
  197. \errorE{#1}\fi\fi
  198. \csname E#1\endcsname}
  199. \def\errorE#1{
  200. {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
  201.  
  202. % Single-spacing is done by various environments.
  203.  
  204. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  205. \def\singlespace{%
  206. {\advance \baselineskip by -\singlespaceskip
  207. \kern \baselineskip}%
  208. \baselineskip=\singlespaceskip
  209. }
  210.  
  211. %% Simple single-character @ commands
  212.  
  213. % @@ prints an @
  214. % Kludge this until the fonts are right (grr).
  215. \def\@{{\tt \char '100}}
  216.  
  217. % Define @` and @' to be the same as ` and '
  218. % but suppressing ligatures.
  219. \def\`{{`}}
  220. \def\'{{'}}
  221.  
  222. % Used to generate quoted braces.
  223.  
  224. \def\mylbrace {{\tt \char '173}}
  225. \def\myrbrace {{\tt \char '175}}
  226. \let\{=\mylbrace
  227. \let\}=\myrbrace
  228.  
  229. % @: forces normal size whitespace following.
  230. \def\:{\spacefactor=1000 }
  231.  
  232. % @* forces a line break.
  233. \def\*{\hfil\break}
  234.  
  235. % @. is an end-of-sentence period.
  236. \def\.{.\spacefactor=3000 }
  237.  
  238. % @w prevents a word break
  239. \def\w #1{\hbox{#1}}
  240.  
  241. % @group ... @end group  forces ... to be all on one page.
  242.  
  243. \def\group{\begingroup% \inENV ???
  244. \def \Egroup{\egroup\endgroup}
  245. \vbox\bgroup}
  246.  
  247. % @br   forces paragraph break
  248.  
  249. \let\br = \par
  250.  
  251. % @dots{}  output some dots
  252.  
  253. \def\dots{$\ldots$}
  254.  
  255. % @page    forces the start of a new page
  256.  
  257. \def\page{\par\vfill\supereject}
  258.  
  259. % @exdent text....
  260. % outputs text on separate line in roman font, starting at standard page margin
  261.  
  262. \def\exdent{\errmessage{@exdent in filled text}}
  263.   % @lisp, etc, define \exdent locally from \internalexdent
  264.  
  265. {\obeyspaces
  266. \gdef\internalexdent{\parsearg\exdentzzz}}
  267.  
  268. \def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
  269. \advance \hsize by -\leftskip
  270. \advance \hsize by -\rightskip
  271. \leftline{{\rm#1}}}}
  272.  
  273. % @include file    insert text of that file as input.
  274.  
  275. \def\include{\parsearg\includezzz}
  276. \def\includezzz #1{{\def\thisfile{#1}\input #1
  277. }}
  278.  
  279. \def\thisfile{}
  280.  
  281. % @center line   outputs that line, centered
  282.  
  283. \def\center{\parsearg\centerzzz}
  284. \def\centerzzz #1{{\advance\hsize by -\leftskip
  285. \advance\hsize by -\rightskip
  286. \centerline{#1}}}
  287.  
  288. % @sp n   outputs n lines of vertical space
  289.  
  290. \def\sp{\parsearg\spxxx}
  291. \def\spxxx #1{\par \vskip #1\baselineskip}
  292.  
  293. % @comment ...line which is ignored...
  294. % @c is the same as @comment
  295. % @ignore ... @end ignore  is another way to write a comment
  296.  
  297. \def\comment{\parsearg \commentxxx}
  298.  
  299. \def\commentxxx #1{}
  300.  
  301. \let\c=\comment
  302.  
  303. % Prevent errors for section commands.
  304. % Used in @ignore and in failing conditionals.
  305. \def\ignoresections{%
  306. \let\chapter=\relax
  307. \let\unnumbered=\relax
  308. \let\unnumberedsec=\relax
  309. \let\unnumberedsection=\relax
  310. \let\unnumberedsubsec=\relax
  311. \let\unnumberedsubsection=\relax
  312. \let\unnumberedsubsubsec=\relax
  313. \let\unnumberedsubsubsection=\relax
  314. \let\section=\relax
  315. \let\subsec=\relax
  316. \let\subsubsec=\relax
  317. \let\subsection=\relax
  318. \let\subsubsection=\relax
  319. \let\appendix=\relax
  320. \let\appendixsec=\relax
  321. \let\appendixsection=\relax
  322. \let\appendixsubsec=\relax
  323. \let\appendixsubsection=\relax
  324. \let\appendixsubsubsec=\relax
  325. \let\appendixsubsubsection=\relax
  326. }
  327.  
  328. \def\ignore{\begingroup\ignoresections\ignorexxx}
  329. \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
  330.  
  331. % Conditionals to test whether a flag is set.
  332.  
  333. \outer\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  334.  
  335. \def\ifsetxxx #1{\endgroup
  336. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
  337. \else \let\temp=\relax \fi
  338. \temp}
  339. \def\Eifset{}
  340. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  341. \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
  342.  
  343. \outer\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  344.  
  345. \def\ifclearxxx #1{\endgroup
  346. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
  347. \else \let\temp=\ifclearfail \fi
  348. \temp}
  349. \def\Eifclear{}
  350. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  351. \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
  352.  
  353. % Some texinfo constructs that are trivial in tex
  354.  
  355. \def\iftex{}
  356. \def\Eiftex{}
  357. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  358. \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
  359.  
  360. \long\def\menu #1\end menu{}
  361. \def\asis#1{#1}
  362.  
  363. \def\node{\ENVcheck\parsearg\nodezzz}
  364. \def\nodezzz#1{\nodexxx [#1,]}
  365. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  366. \let\lastnode=\relax
  367.  
  368. \def\donoderef{\ifx\lastnode\relax\else
  369. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  370. \let\lastnode=\relax}
  371.  
  372. \def\unnumbnoderef{\ifx\lastnode\relax\else
  373. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  374. \let\lastnode=\relax}
  375.  
  376. \def\appendixnoderef{\ifx\lastnode\relax\else
  377. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  378. \let\lastnode=\relax}
  379.  
  380. \let\refill=\relax
  381.   
  382. % @setfilename is done at the beginning of every texinfo file.
  383. % So open here the files we need to have open while reading the input.
  384. % This makes it possible to make a .fmt file for texinfo.
  385. \def\setfilename{%
  386.    \readauxfile
  387.    \opencontents
  388.    \openindices
  389.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  390.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  391.    \comment % Ignore the actual filename.
  392. }
  393.  
  394. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  395.  
  396. \def\inforef #1{\inforefzzz #1,,,,**}
  397. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node `\losespace#1{}'}
  398. \def\losespace #1{#1}
  399.  
  400. \message{fonts,}
  401.  
  402. % Font-change commands.
  403.  
  404. %% Try out Computer Modern fonts at \magstephalf
  405. \font\tenrm=cmr10 scaled \magstephalf
  406. \font\tentt=cmtt10 scaled \magstephalf
  407. % Instead of cmb10, you many want to use cmbx10.
  408. % cmbx10 is a prettier font on its own, but cmb10
  409. % looks better when embedded in a line with cmr10.
  410. %!%\font\tenbf=cmb10 scaled \magstephalf 
  411. \font\tenbf=cmbx10 scaled \magstephalf %!%
  412. \font\tenit=cmti10 scaled \magstephalf
  413. \font\tensl=cmsl10 scaled \magstephalf
  414. \font\tensf=cmss10 scaled \magstephalf
  415. \def\li{\sf}
  416. \font\tensc=cmcsc10 scaled \magstephalf
  417.  
  418. % Fonts for @defun, etc.
  419. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  420. \font\deftt=cmtt10 scaled \magstep1
  421. \def\df{\let\tt=\deftt \defbf}
  422.  
  423. % Font for title
  424. % There seems to have been a confusion: two definitions of this font.
  425. % It is not clear why, or which one is better.
  426. \font\titlerm = cmbx10 scaled \magstep5
  427. % this is too small -- rms, May 1990.
  428. %\font\titlerm = cmbx12 scaled \magstep2
  429.  
  430. % Fonts for indices
  431. \font\ninett=cmtt9
  432. \font\indit=cmti9 \font\indrm=cmr9
  433. \let\indtt=\ninett
  434. \def\indbf{\indrm} \def\indsl{\indit}
  435. \def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm
  436. \let\tt=\indtt}
  437.  
  438. % Fonts for headings
  439. \font\chaprm=cmbx10 scaled \magstep3
  440. \font\chapit=cmti10 scaled \magstep3
  441. \font\chapsl=cmsl10 scaled \magstep3
  442. \font\chaptt=cmtt10 scaled \magstep3
  443. \font\chapsf=cmss10 scaled \magstep3
  444. \let\chapbf=\chaprm
  445.  
  446. \font\secrm=cmbx10 scaled \magstep2
  447. \font\secit=cmti10 scaled \magstep2
  448. \font\secsl=cmsl10 scaled \magstep2
  449. \font\sectt=cmtt10 scaled \magstep2
  450. \font\secsf=cmss10 scaled \magstep2
  451. \let\secbf=\secrm
  452.  
  453. %!% Use this again:
  454. \font\ssecrm=cmbx10 scaled \magstep1    % This size an fontlooked bad.
  455. \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  456. \font\ssecsl=cmsl10 scaled \magstep1
  457. \font\ssectt=cmtt10 scaled \magstep1
  458. \font\ssecsf=cmss10 scaled \magstep1
  459.  
  460. %!% \font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  461. %!% \font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  462. %!% \font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  463. %!% \font\ssectt=cmtt10 scaled 1315
  464. %!% \font\ssecsf=cmss10 scaled 1315
  465.  
  466. \let\ssecbf=\ssecrm
  467.  
  468. \def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
  469. \let\smallcaps=\tensc\let\sf=\tensf}
  470. \def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
  471. \def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
  472. \def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
  473. % Count depth in font-changes, for error checks
  474. \newcount\fontdepth \fontdepth=0
  475.  
  476. % Font for table of contents.
  477. \font\truesecrm=cmr12
  478.  
  479. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  480. %% serif) and @ii for TeX italic
  481.  
  482. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  483. % unless the following character is such as not to need one.
  484. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  485. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  486.  
  487. \let\i=\smartitalic
  488. \let\var=\smartitalic
  489. \let\dfn=\smartitalic
  490. \let\emph=\smartitalic
  491. \let\cite=\smartitalic
  492.  
  493. \def\b#1{{\bf #1}}
  494. \let\strong=\b
  495.  
  496. \def\t#1{{\tt \rawbackslash \frenchspacing #1}\null}
  497. \let\ttfont = \t
  498. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  499. \def\samp #1{`\tclose{#1}'\null}
  500. \def\key #1{{\tt \uppercase{#1}}\null}
  501. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  502.  
  503. \let\file=\samp
  504.  
  505. % @code is a modification of @t,
  506. % which makes spaces the same size as normal in the surrounding text.
  507. \newdimen\tclosesave
  508. \newdimen\tcloserm
  509. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  510. \fontdimen2\font=\tcloserm
  511. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  512.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  513. \let\code=\tclose
  514. %\let\exp=\tclose  %Was temporary
  515.  
  516. % @kbd is like @code, except that if the argument is just one @key command, 
  517. % then @kbd has no effect.
  518.  
  519. \def\xkey{\key}
  520. \def\kbdfoo#1#2#3*{\def\one{#1}\def\three{#3}\def\threex{??}%
  521. \ifx\one\xkey\ifx\threex\three \key{#2}%
  522. \else\tclose{\look}\fi
  523. \else\tclose{\look}\fi}
  524.  
  525. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??*}
  526.  
  527. \def\l#1{{\li #1}\null}        % 
  528.  
  529. \def\r#1{{\rm #1}}        % roman font
  530. \def\sc#1{{\smallcaps #1}}    % smallcaps font
  531. \def\ii#1{{\it #1}}        % italic font
  532.  
  533. \message{page headings,}
  534.  
  535. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  536. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  537.  
  538. % First the title page.  Must do @settitle before @titlepage.
  539. \def\titlefont#1{{\titlerm #1}}
  540.  
  541. \newtoks\realeverypar
  542. \newif\ifseenauthor
  543. \newif\iffinishedtitlepage
  544.  
  545. \def\titlepage{\begingroup \parindent=0pt \textfonts
  546.    \let\subtitlerm=\tenrm
  547.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  548.    %
  549.    \font\authorrm = cmbx12 scaled \magstep1
  550.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  551.    %
  552.    % Leave some space at the very top of the page.
  553.    \vglue\titlepagetopglue
  554.    %
  555.    % Now you can print the title using @title.
  556.    \def\title{\parsearg\titlezzz}%
  557.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  558.             % print a rule at the page bottom also.
  559.             \finishedtitlepagefalse
  560.             %!% \vskip4pt \hrule height 4pt \vskip4pt
  561.                    }%
  562.    % No rule at page bottom unless we print one at the top with @title.
  563.    \finishedtitlepagetrue
  564.    %
  565.    % Now you can put text using @subtitle.
  566.    \def\subtitle{\parsearg\subtitlezzz}%
  567.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  568.    %
  569.    % @author should come last, but may come many times.
  570.    \def\author{\parsearg\authorzzz}%
  571.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  572.       {\authorfont \leftline{##1}}}%
  573.    %  
  574.    % Most title ``pages'' are actually two pages long, with space
  575.    % at the top of the second.  We don't want the ragged left on the second.
  576.    \let\oldpage = \page
  577.    \def\page{%
  578.       \finishtitlepage
  579.       \oldpage
  580.       \let\page = \oldpage
  581.       \hbox{}}%
  582. %   \def\page{\oldpage \hbox{}}
  583. }
  584.  
  585. \def\Etitlepage{%
  586.    \iffinishedtitlepage\else
  587.       \finishtitlepage
  588.    \fi
  589.    \endgroup\page\HEADINGSon
  590. }
  591.  
  592. \def\finishtitlepage{%
  593.    %!% \vskip4pt \hrule height 2pt
  594.    \vskip\titlepagebottomglue
  595.    \finishedtitlepagetrue
  596. }
  597.  
  598. %%% Set up page headings and footings.
  599.  
  600. \let\thispage=\folio
  601.  
  602. \newtoks \evenheadline    % Token sequence for heading line of even pages
  603. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  604. \newtoks \evenfootline    % Token sequence for footing line of even pages
  605. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  606.  
  607. % Now make Tex use those variables
  608. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
  609. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}}
  610.  
  611. % Commands to set those variables.
  612. % For example, this is what  @headings on  does
  613. % @evenheading @thistitle|@thispage|@thischapter
  614. % @oddheading @thischapter|@thispage|@thistitle
  615. % @evenfooting @thisfile||
  616. % @oddfooting ||@thisfile
  617.  
  618. \def\evenheading{\parsearg\evenheadingxxx}
  619. \def\oddheading{\parsearg\oddheadingxxx}
  620. \def\everyheading{\parsearg\everyheadingxxx}
  621.  
  622. \def\evenfooting{\parsearg\evenfootingxxx}
  623. \def\oddfooting{\parsearg\oddfootingxxx}
  624. \def\everyfooting{\parsearg\everyfootingxxx}
  625.  
  626. {\catcode`\@=0 %
  627.  
  628. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  629. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  630. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  631.  
  632. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  633. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  634. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  635.  
  636. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  637. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  638. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  639. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  640.  
  641. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  642. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  643. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  644.  
  645. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  646. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  647. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  648.  
  649. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  650. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  651. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  652. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  653. %
  654. }% unbind the catcode of @.
  655.  
  656. % @headings double    turns headings on for double-sided printing.
  657. % @headings single    turns headings on for single-sided printing.
  658. % @headings off        turns them off.
  659. % @headings on        same as @headings double, retained for compatibility.
  660. % By default, they are off.
  661.  
  662. \def\headings #1 {\csname HEADINGS#1\endcsname}
  663.  
  664. \def\HEADINGSoff{
  665. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  666. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  667. \HEADINGSoff
  668. % When we turn headings on, set the page number to 1.
  669. % For double-sided printing, put current file name in lower left corner,
  670. % chapter name on inside top of right hand pages, document
  671. % title on inside top of left hand pages, and page numbers on outside top
  672. % edge of all pages.
  673. \def\HEADINGSdouble{
  674. %\pagealignmacro
  675. \global\pageno=1
  676. \global\evenfootline={\hfil}
  677. \global\oddfootline={\hfil}
  678. \global\evenheadline={\line{\folio\hfil\thistitle}}
  679. \global\oddheadline={\line{\thischapter\hfil\folio}}
  680. }
  681. % For single-sided printing, chapter title goes across top left of page,
  682. % page number on top right.
  683. \def\HEADINGSsingle{
  684. %\pagealignmacro
  685. \global\pageno=1
  686. \global\evenfootline={\hfil}
  687. \global\oddfootline={\hfil}
  688. \global\evenheadline={\line{\thischapter\hfil\folio}}
  689. \global\oddheadline={\line{\thischapter\hfil\folio}}
  690. }
  691. \def\HEADINGSon{\HEADINGSdouble}
  692.  
  693. % Subroutines used in generating headings
  694. % Produces Day Month Year style of output.
  695. \def\today{\number\day\space
  696. \ifcase\month\or
  697. January\or February\or March\or April\or May\or June\or
  698. July\or August\or September\or October\or November\or December\fi
  699. \space\number\year}
  700.  
  701. % Use this if you want the Month Day, Year style of output.
  702. %\def\today{\ifcase\month\or
  703. %January\or February\or March\or April\or May\or June\or
  704. %July\or August\or September\or October\or November\or December\fi
  705. %\space\number\day, \number\year}
  706.  
  707. % @settitle line...  specifies the title of the document, for headings
  708. % It generates no output of its own
  709.  
  710. \def\thistitle{No Title}
  711. \def\settitle{\parsearg\settitlezzz}
  712. \def\settitlezzz #1{\gdef\thistitle{#1}}
  713.  
  714. \message{tables,}
  715.  
  716. % @tabs -- simple alignment
  717.  
  718. % These don't work.  For one thing, \+ is defined as outer.
  719. % So these macros cannot even be defined.
  720.  
  721. %\def\tabs{\parsearg\tabszzz}
  722. %\def\tabszzz #1{\settabs\+#1\cr}
  723. %\def\tabline{\parsearg\tablinezzz}
  724. %\def\tablinezzz #1{\+#1\cr}
  725. %\def\&{&}
  726.  
  727. % Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
  728.  
  729. % default indentation of table text
  730. \newdimen\tableindent \tableindent=.8in
  731. % default indentation of @itemize and @enumerate text
  732. \newdimen\itemindent  \itemindent=.3in
  733. % margin between end of table item and start of table text.
  734. \newdimen\itemmargin  \itemmargin=.1in
  735.  
  736. % used internally for \itemindent minus \itemmargin
  737. \newdimen\itemmax
  738.  
  739. % Note @table and @ftable define @item, @itemx, etc., with these defs.
  740. % They also define \itemindex
  741. % to index the item name in whatever manner is desired (perhaps none).
  742.  
  743. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  744. \def\internalBitemx{\par \parsearg\itemzzz}
  745.  
  746. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  747. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  748.  
  749. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  750. \def\internalBkitemx{\par \parsearg\kitemzzz}
  751.  
  752. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
  753.  
  754. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
  755.  
  756. \def\itemzzz #1{\begingroup %
  757. \advance \hsize by -\rightskip %
  758. \advance \hsize by -\leftskip %
  759. \setbox0=\hbox{\itemfont{#1}}%
  760. \itemindex{#1}%
  761. \parskip=0in %
  762. \noindent %
  763. \ifdim \wd0>\itemmax %
  764. \vadjust{\penalty 10000}%
  765. \hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
  766. \else %
  767. \hbox to 0pt{\hskip -\tableindent\box0\hss}%
  768. \fi %
  769. \endgroup %
  770. }
  771.  
  772. \def\item{\errmessage{@item while not in a table}}
  773. \def\itemx{\errmessage{@itemx while not in a table}}
  774. \def\kitem{\errmessage{@kitem while not in a table}}
  775. \def\kitemx{\errmessage{@kitemx while not in a table}}
  776. \def\xitem{\errmessage{@xitem while not in a table}}
  777. \def\xitemx{\errmessage{@xitemx while not in a table}}
  778.  
  779. %% Contains a kludge to get @end[description] to work
  780. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  781.  
  782. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  783. {\obeylines\obeyspaces%
  784. \gdef\tablex #1^^M{%
  785. \tabley\dontindex#1        \endtabley}}
  786.  
  787. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  788. {\obeylines\obeyspaces%
  789. \gdef\ftablex #1^^M{%
  790. \tabley\fnitemindex#1        \endtabley}}
  791.  
  792. \def\dontindex #1{}
  793. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  794.  
  795. {\obeyspaces %
  796. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  797. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  798.  
  799. \def\tablez #1#2#3#4#5#6{%
  800. \aboveenvbreak %
  801. \begingroup %
  802. \def\Edescription{\Etable}% Neccessary kludge.
  803. \let\itemindex=#1%
  804. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  805. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  806. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  807. \def\itemfont{#2}%
  808. \itemmax=\tableindent %
  809. \advance \itemmax by -\itemmargin %
  810. \advance \leftskip by \tableindent %
  811. \parindent = 0pt
  812. \parskip = \smallskipamount
  813. \ifdim \parskip=0pt \parskip=2pt \fi%
  814. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  815. \let\item = \internalBitem %
  816. \let\itemx = \internalBitemx %
  817. \let\kitem = \internalBkitem %
  818. \let\kitemx = \internalBkitemx %
  819. \let\xitem = \internalBxitem %
  820. \let\xitemx = \internalBxitemx %
  821. }
  822.  
  823. % This is the counter used by @enumerate, which is really @itemize
  824.  
  825. \newcount \itemno
  826.  
  827. \def\itemize{\parsearg\itemizezzz}
  828.  
  829. \def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
  830.  
  831. \def\itemizey #1#2{%
  832. \aboveenvbreak %
  833. \begingroup %
  834. \itemno = 0 %
  835. \itemmax=\itemindent %
  836. \advance \itemmax by -\itemmargin %
  837. \advance \leftskip by \itemindent %
  838. \parindent = 0pt
  839. \parskip = \smallskipamount
  840. \ifdim \parskip=0pt \parskip=2pt \fi%
  841. \def#2{\endgraf\endgroup\afterenvbreak}%
  842. \def\itemcontents{#1}%
  843. \let\item=\itemizeitem}
  844.  
  845. \def\bullet{$\ptexbullet$}
  846. \def\minus{$-$}
  847.  
  848. % Set sfcode to normal for the chars that usually have another value.
  849. % These are `.?!:;,'
  850. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  851.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  852.  
  853. \def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
  854.  
  855. % Definition of @item while inside @itemize.
  856.  
  857. \def\itemizeitem{%
  858. \advance\itemno by 1
  859. {\let\par=\endgraf \smallbreak}%
  860. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  861. {\parskip=0in \hskip 0pt
  862. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  863. \vadjust{\penalty 300}}%
  864. \flushcr}
  865.  
  866. \message{indexing,}
  867. % Index generation facilities
  868.  
  869. % Define \newwrite to be identical to plain tex's \newwrite
  870. % except not \outer, so it can be used within \newindex.
  871. {\catcode`\@=11
  872. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  873.  
  874. % \newindex {foo} defines an index named foo.
  875. % It automatically defines \fooindex such that
  876. % \fooindex ...rest of line... puts an entry in the index foo.
  877. % It also defines \fooindfile to be the number of the output channel for
  878. % the file that    accumulates this index.  The file's extension is foo.
  879. % The name of an index should be no more than 2 characters long
  880. % for the sake of vms.
  881.  
  882. \def\newindex #1{
  883. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  884. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  885. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  886. \noexpand\doindex {#1}}
  887. }
  888.  
  889. % @defindex foo  ==  \newindex{foo}
  890.  
  891. \def\defindex{\parsearg\newindex}
  892.  
  893. % Define @defcodeindex, like @defindex except put all entries in @code.
  894.  
  895. \def\newcodeindex #1{
  896. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  897. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  898. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  899. \noexpand\docodeindex {#1}}
  900. }
  901.  
  902. \def\defcodeindex{\parsearg\newcodeindex}
  903.  
  904. % @synindex foo bar    makes index foo feed into index bar.
  905. % Do this instead of @defindex foo if you don't want it as a separate index.
  906. \def\synindex #1 #2 {%
  907. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  908. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  909. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  910. \noexpand\doindex {#2}}%
  911. }
  912.  
  913. % @syncodeindex foo bar   similar, but put all entries made for index foo
  914. % inside @code.
  915. \def\syncodeindex #1 #2 {%
  916. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  917. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  918. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  919. \noexpand\docodeindex {#2}}%
  920. }
  921.  
  922. % Define \doindex, the driver for all \fooindex macros.
  923. % Argument #1 is generated by the calling \fooindex macro,
  924. %  and it is "foo", the name of the index.
  925.  
  926. % \doindex just uses \parsearg; it calls \doind for the actual work.
  927. % This is because \doind is more useful to call from other macros.
  928.  
  929. % There is also \dosubind {index}{topic}{subtopic}
  930. % which makes an entry in a two-level index such as the operation index.
  931.  
  932. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  933. \def\singleindexer #1{\doind{\indexname}{#1}}
  934.  
  935. % like the previous two, but they put @code around the argument.
  936. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  937. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  938.  
  939. \def\indexdummies{%
  940. \def\w{\realbackslash w }%
  941. \def\bf{\realbackslash bf }%
  942. \def\rm{\realbackslash rm }%
  943. \def\sl{\realbackslash sl }%
  944. \def\sf{\realbackslash sf}%
  945. \def\tt{\realbackslash tt}%
  946. \def\gtr{\realbackslash gtr}%
  947. \def\less{\realbackslash less}%
  948. \def\hat{\realbackslash hat}%
  949. \def\char{\realbackslash char}%
  950. \def\TeX{\realbackslash TeX}%
  951. \def\dots{\realbackslash dots }%
  952. \def\copyright{\realbackslash copyright }%
  953. \def\tclose##1{\realbackslash tclose {##1}}%
  954. \def\code##1{\realbackslash code {##1}}%
  955. \def\samp##1{\realbackslash samp {##1}}%
  956. \def\r##1{\realbackslash r {##1}}%
  957. \def\i##1{\realbackslash i {##1}}%
  958. \def\b##1{\realbackslash b {##1}}%
  959. \def\cite##1{\realbackslash cite {##1}}%
  960. \def\key##1{\realbackslash key {##1}}%
  961. \def\file##1{\realbackslash file {##1}}%
  962. \def\var##1{\realbackslash var {##1}}%
  963. \def\kbd##1{\realbackslash kbd {##1}}%
  964. }
  965.  
  966. % \indexnofonts no-ops all font-change commands.
  967. % This is used when outputting the strings to sort the index by.
  968. \def\indexdummyfont#1{#1}
  969. \def\indexnofonts{%
  970. \let\w=\indexdummyfont
  971. \let\r=\indexdummyfont
  972. \let\i=\indexdummyfont
  973. \let\b=\indexdummyfont
  974. \let\emph=\indexdummyfont
  975. \let\strong=\indexdummyfont
  976. \let\cite=\indexdummyfont
  977. \let\sc=\indexdummyfont
  978. %Don't no-op \tt, since it isn't a user-level command
  979. % and is used in the definitions of the actuve chars like <, >, |...
  980. %\let\tt=\indexdummyfont
  981. \let\tclose=\indexdummyfont
  982. \let\code=\indexdummyfont
  983. \let\file=\indexdummyfont
  984. \let\samp=\indexdummyfont
  985. \let\kbd=\indexdummyfont
  986. \let\key=\indexdummyfont
  987. \let\var=\indexdummyfont
  988. }
  989.  
  990. % To define \realbackslash, we must make \ not be an escape.
  991. % We must first make another character (@) an escape
  992. % so we do not become unable to do a definition.
  993.  
  994. {\catcode`\@=0 \catcode`\\=\other
  995. @gdef@realbackslash{\}}
  996.  
  997. \let\indexbackslash=0  %overridden during \printindex.
  998.  
  999. \def\doind #1#2{%
  1000. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1001. \count10=\lastpenalty %
  1002. \escapechar=`\\%
  1003. {\let\folio=0% Expand all macros now EXCEPT \folio
  1004. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1005. % so it will be output as is; and it will print as backslash in the indx.
  1006. %
  1007. % Now process the index-string once, with all font commands turned off,
  1008. % to get the string to sort the index by.
  1009. {\indexnofonts
  1010. \xdef\temp1{#2}%
  1011. }%
  1012. % Now produce the complete index entry.  We process the index-string again,
  1013. % this time with font commands expanded, to get what to print in the index.
  1014. \edef\temp{%
  1015. \write \csname#1indfile\endcsname{%
  1016. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1017. \temp }%
  1018. \penalty\count10}}
  1019.  
  1020. \def\dosubind #1#2#3{%
  1021. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1022. \count10=\lastpenalty %
  1023. \escapechar=`\\%
  1024. {\let\folio=0%
  1025. \def\rawbackslashxx{\indexbackslash}%
  1026. %
  1027. % Now process the index-string once, with all font commands turned off,
  1028. % to get the string to sort the index by.
  1029. {\indexnofonts
  1030. \xdef\temp1{#2 #3}%
  1031. }%
  1032. % Now produce the complete index entry.  We process the index-string again,
  1033. % this time with font commands expanded, to get what to print in the index.
  1034. \edef\temp{%
  1035. \write \csname#1indfile\endcsname{%
  1036. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1037. \temp }%
  1038. \penalty\count10}}
  1039.  
  1040. % The index entry written in the file actually looks like
  1041. %  \entry {sortstring}{page}{topic}
  1042. % or
  1043. %  \entry {sortstring}{page}{topic}{subtopic}
  1044. % The texindex program reads in these files and writes files
  1045. % containing these kinds of lines:
  1046. %  \initial {c}
  1047. %     before the first topic whose initial is c
  1048. %  \entry {topic}{pagelist}
  1049. %     for a topic that is used without subtopics
  1050. %  \primary {topic}
  1051. %     for the beginning of a topic that is used with subtopics
  1052. %  \secondary {subtopic}{pagelist}
  1053. %     for each subtopic.
  1054.  
  1055. % Define the user-accessible indexing commands 
  1056. % @findex, @vindex, @kindex, @cindex.
  1057.  
  1058. \def\findex {\fnindex}
  1059. \def\kindex {\kyindex}
  1060. \def\cindex {\cpindex}
  1061. \def\vindex {\vrindex}
  1062. \def\tindex {\tpindex}
  1063. \def\pindex {\pgindex}
  1064.  
  1065. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1066. {\obeylines %
  1067. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1068. \dosubind{cp}{#2}{#1}}}
  1069.  
  1070. % Define the macros used in formatting output of the sorted index material.
  1071.  
  1072. % This is what you call to cause a particular index to get printed.
  1073. % Write
  1074. % @unnumbered Function Index
  1075. % @printindex fn
  1076.  
  1077. \def\printindex{\parsearg\doprintindex}
  1078.  
  1079. \def\doprintindex#1{\tex %
  1080. \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1081. \catcode`\$=\other\catcode`\_=\other
  1082. \catcode`\~=\other
  1083. % The following don't help, since the chars were translated
  1084. % when the raw index was written, and their fonts were discarded
  1085. % due to \indexnofonts.
  1086. %\catcode`\"=\active
  1087. %\catcode`\^=\active
  1088. %\catcode`\_=\active
  1089. %\catcode`\|=\active
  1090. %\catcode`\<=\active
  1091. %\catcode`\>=\active
  1092. \def\indexbackslash{\rawbackslashxx}
  1093. \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1094. \begindoublecolumns
  1095. \openin 1 \jobname.#1s
  1096. \ifeof 1 \else \closein 1 \input \jobname.#1s
  1097. \fi
  1098. \enddoublecolumns
  1099. \Etex}
  1100.  
  1101. % These macros are used by the sorted index file itself.
  1102. % Change them to control the appearance of the index.
  1103.  
  1104. % Same as \bigskipamount except no shrink.
  1105. % \balancecolumns gets confused if there is any shrink.
  1106. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1107.  
  1108. \outer\def\initial #1{%
  1109. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1110. \ifdim\lastskip<\initialskipamount
  1111. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1112. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1113.  
  1114. \outer\def\entry #1#2{
  1115. {\parfillskip=0in \parskip=0in \parindent=0in
  1116. \hangindent=1in \hangafter=1%
  1117. \noindent\hbox{#1}\dotfill #2\par
  1118. }}
  1119.  
  1120. \def\primary #1{\line{#1\hfil}}
  1121.  
  1122. \newskip\secondaryindent \secondaryindent=0.5cm
  1123.  
  1124. \def\secondary #1#2{
  1125. {\parfillskip=0in \parskip=0in
  1126. \hangindent =1in \hangafter=1
  1127. \noindent\hskip\secondaryindent\hbox{#1}\dotfill #2\par
  1128. }}
  1129.  
  1130. %% Define two-column mode, which is used in indexes.
  1131. %% Adapted from the TeXBook, page 416
  1132. \catcode `\@=11
  1133.  
  1134. \newbox\partialpage
  1135.  
  1136. \newdimen\doublecolumnhsize  \doublecolumnhsize = 3.11in
  1137. \newdimen\doublecolumnvsize  \doublecolumnvsize = 19.1in
  1138. \newdimen\availdimen@
  1139.  
  1140. \def\begindoublecolumns{\begingroup
  1141.   \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
  1142.   \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
  1143. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1144.   \endgroup \pagegoal=\vsize}
  1145.  
  1146. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1147.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1148.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1149.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1150. \def\pagesofar{\unvbox\partialpage %
  1151.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1152. %          changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1153.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1154. \def\balancecolumns{%
  1155. % Unset the glue.
  1156.   \setbox255=\vbox{\unvbox255}
  1157.   \dimen@=\ht255
  1158.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1159.   \divide\dimen@ by2
  1160.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1161. % If the remaining data is too big for one page,
  1162. % output one page normally, then work with what remains.
  1163.   \ifdim \dimen@>\availdimen@
  1164.    {
  1165.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1166.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1167.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1168.      \onepageout\pagesofar
  1169.    }
  1170. % Recompute size of what remains, in case we just output some of it.
  1171.   \dimen@=\ht255
  1172.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1173.   \divide\dimen@ by2
  1174.   \fi
  1175.   \setbox0=\vbox{\unvbox255}
  1176.   \splittopskip=\topskip
  1177.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1178.     \global\setbox1=\vsplit3 to\dimen@
  1179.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1180.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1181.   \pagesofar}
  1182.  
  1183. \catcode `\@=\other
  1184. \message{sectioning,}
  1185. % Define chapters, sections, etc.
  1186.  
  1187. \newcount \chapno
  1188. \newcount \secno
  1189. \newcount \subsecno
  1190. \newcount \subsubsecno
  1191.  
  1192. % This counter is funny since it counts through charcodes of letters A, B, ...
  1193. \newcount \appendixno  \appendixno = `\@
  1194. \def\appendixletter{\char\the\appendixno}
  1195.  
  1196. \newwrite \contentsfile
  1197. % This is called from \setfilename.
  1198. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1199.  
  1200. % Each @chapter defines this as the name of the chapter.
  1201. % page headings and footings can use it.  @section does likewise
  1202.  
  1203. \def\thischapter{} \def\thissection{}
  1204. \def\seccheck#1{\if \pageno<0 %
  1205. \errmessage{@#1 not allowed after generating table of contents}\fi
  1206. %
  1207. }
  1208.  
  1209. \def\chapternofonts{%
  1210. \let\rawbackslash=\relax%
  1211. \let\frenchspacing=\relax%
  1212. \def\TeX{\realbackslash TeX}
  1213. \def\dots{\realbackslash dots}
  1214. \def\copyright{\realbackslash copyright}
  1215. \def\tt{\realbackslash tt}
  1216. \def\bf{\realbackslash bf }
  1217. \def\w{\realbackslash w}
  1218. \def\less{\realbackslash less}
  1219. \def\gtr{\realbackslash gtr}
  1220. \def\hat{\realbackslash hat}
  1221. \def\char{\realbackslash char}
  1222. \def\tclose##1{\realbackslash tclose {##1}}
  1223. \def\code##1{\realbackslash code {##1}}
  1224. \def\samp##1{\realbackslash samp {##1}}
  1225. \def\r##1{\realbackslash r {##1}}
  1226. \def\b##1{\realbackslash b {##1}}
  1227. \def\key##1{\realbackslash key {##1}}
  1228. \def\file##1{\realbackslash file {##1}}
  1229. \def\kbd##1{\realbackslash kbd {##1}}
  1230. % These are redefined because @smartitalic wouldn't work inside xdef.
  1231. \def\i##1{\realbackslash i {##1}}
  1232. \def\cite##1{\realbackslash cite {##1}}
  1233. \def\var##1{\realbackslash var {##1}}
  1234. \def\emph##1{\realbackslash emph {##1}}
  1235. \def\dfn##1{\realbackslash dfn {##1}}
  1236. }
  1237.  
  1238. \outer\def\chapter{\parsearg\chapterzzz}
  1239. \def\chapterzzz #1{\seccheck{chapter}%
  1240. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1241. \chapmacro {#1}{\the\chapno}%
  1242. \gdef\thissection{#1}%
  1243. \gdef\thischaptername{#1}%
  1244. % We don't substitute the actual chapter name into \thischapter
  1245. % because we don't want its macros evaluated now.
  1246. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1247. {\chapternofonts%
  1248. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1249. \escapechar=`\\%
  1250. \write \contentsfile \temp  %
  1251. \donoderef %
  1252. }}
  1253.  
  1254. \outer\def\appendix{\parsearg\appendixzzz}
  1255. \def\appendixzzz #1{\seccheck{appendix}%
  1256. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1257. \chapmacro {#1}{Appendix \appendixletter}%
  1258. \gdef\thissection{#1}%
  1259. \gdef\thischaptername{#1}%
  1260. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1261. {\chapternofonts%
  1262. \edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1263. \escapechar=`\\%
  1264. \write \contentsfile \temp  %
  1265. \appendixnoderef %
  1266. }}
  1267.  
  1268. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1269. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1270. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1271. \unnumbchapmacro {#1}%
  1272. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1273. {\chapternofonts%
  1274. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1275. \escapechar=`\\%
  1276. \write \contentsfile \temp  %
  1277. \unnumbnoderef %
  1278. }}
  1279.  
  1280. \outer\def\section{\parsearg\sectionzzz}
  1281. \def\sectionzzz #1{\seccheck{section}%
  1282. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1283. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1284. {\chapternofonts%
  1285. \edef\temp{{\realbackslash secentry %
  1286. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1287. \escapechar=`\\%
  1288. \write \contentsfile \temp %
  1289. \donoderef %
  1290. \penalty 10000 %
  1291. }}
  1292.  
  1293. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1294. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1295. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1296. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1297. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1298. {\chapternofonts%
  1299. \edef\temp{{\realbackslash secentry %
  1300. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1301. \escapechar=`\\%
  1302. \write \contentsfile \temp %
  1303. \appendixnoderef %
  1304. \penalty 10000 %
  1305. }}
  1306.  
  1307. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1308. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1309. \plainsecheading {#1}\gdef\thissection{#1}%
  1310. {\chapternofonts%
  1311. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1312. \escapechar=`\\%
  1313. \write \contentsfile \temp %
  1314. \unnumbnoderef %
  1315. \penalty 10000 %
  1316. }}
  1317.  
  1318. \outer\def\subsection{\parsearg\subsectionzzz}
  1319. \def\subsectionzzz #1{\seccheck{subsection}%
  1320. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1321. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1322. {\chapternofonts%
  1323. \edef\temp{{\realbackslash subsecentry %
  1324. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1325. \escapechar=`\\%
  1326. \write \contentsfile \temp %
  1327. \donoderef %
  1328. \penalty 10000 %
  1329. }}
  1330.  
  1331. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1332. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1333. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1334. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1335. {\chapternofonts%
  1336. \edef\temp{{\realbackslash subsecentry %
  1337. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1338. \escapechar=`\\%
  1339. \write \contentsfile \temp %
  1340. \appendixnoderef %
  1341. \penalty 10000 %
  1342. }}
  1343.  
  1344. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1345. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1346. \plainsecheading {#1}\gdef\thissection{#1}%
  1347. {\chapternofonts%
  1348. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1349. \escapechar=`\\%
  1350. \write \contentsfile \temp %
  1351. \unnumbnoderef %
  1352. \penalty 10000 %
  1353. }}
  1354.  
  1355. \outer\def\subsubsection{\parsearg\subsubsectionzzz}
  1356. \def\subsubsectionzzz #1{\seccheck{subsubsection}%
  1357. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1358. \subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1359. {\chapternofonts%
  1360. \edef\temp{{\realbackslash subsubsecentry %
  1361. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1362. \escapechar=`\\%
  1363. \write \contentsfile \temp %
  1364. \donoderef %
  1365. \penalty 10000 %
  1366. }}
  1367.  
  1368. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1369. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1370. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1371. \subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1372. {\chapternofonts%
  1373. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1374. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1375. \escapechar=`\\%
  1376. \write \contentsfile \temp %
  1377. \appendixnoderef %
  1378. \penalty 10000 %
  1379. }}
  1380.  
  1381. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1382. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1383. \plainsecheading {#1}\gdef\thissection{#1}%
  1384. {\chapternofonts%
  1385. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1386. \escapechar=`\\%
  1387. \write \contentsfile \temp %
  1388. \unnumbnoderef %
  1389. \penalty 10000 %
  1390. }}
  1391.  
  1392. % These are variants which are not "outer", so they can appear in @ifinfo.
  1393. \def\infounnumbered{\parsearg\unnumberedzzz}
  1394. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1395. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1396. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1397.  
  1398. \def\infoappendix{\parsearg\appendixzzz}
  1399. \def\infoappendixsec{\parsearg\appendixseczzz}
  1400. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1401. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1402.  
  1403. \def\infochapter{\parsearg\chapterzzz}
  1404. \def\infosection{\parsearg\sectionzzz}
  1405. \def\infosubsection{\parsearg\subsectionzzz}
  1406. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1407.  
  1408. % Define @majorheading, @heading and @subheading
  1409.  
  1410. \def\majorheading #1{%
  1411. {\advance\chapheadingskip by 10pt \chapbreak }%
  1412. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1413.  
  1414. \def\chapheading #1{\chapbreak %
  1415. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1416.  
  1417. \def\heading{\parsearg\secheadingi}
  1418.  
  1419. % These macros generate a chapter, section, etc. heading only
  1420. % (including whitespace, linebreaking, etc. around it),
  1421. % given all the information in convenient, parsed form.
  1422.  
  1423. %%% Args are the skip and penalty (usually negative)
  1424. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1425.  
  1426. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1427.  
  1428. %%% Define plain chapter starts, and page on/off switching for it
  1429. % Parameter controlling skip before chapter headings (if needed)
  1430.  
  1431. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1432.  
  1433. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1434. \def\chappager{\par\vfill\supereject}
  1435. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1436.  
  1437. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1438.  
  1439. \def\CHAPPAGoff{
  1440. \global\let\pchapsepmacro=\chapbreak
  1441. \global\let\pagealignmacro=\chappager}
  1442.  
  1443. \def\CHAPPAGon{
  1444. \global\let\pchapsepmacro=\chappager
  1445. \global\let\pagealignmacro=\chappager
  1446. \global\def\HEADINGSon{\HEADINGSsingle}}
  1447.  
  1448. \def\CHAPPAGodd{
  1449. \global\let\pchapsepmacro=\chapoddpage
  1450. \global\let\pagealignmacro=\chapoddpage
  1451. \global\def\HEADINGSon{\HEADINGSdouble}}
  1452.  
  1453. \CHAPPAGon
  1454.  
  1455. \def\CHAPFplain{
  1456. \global\let\chapmacro=\chfplain
  1457. \global\let\unnumbchapmacro=\unnchfplain}
  1458.  
  1459. \def\chfplain #1#2{%
  1460. \pchapsepmacro %
  1461. {\chapfonts \line{\rm #2.\enspace #1\hfill}}\bigskip \par\penalty 5000 %
  1462. }
  1463.  
  1464. \def\unnchfplain #1{%
  1465. \pchapsepmacro %
  1466. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1467. }
  1468. \CHAPFplain % The default
  1469.  
  1470. \def\unnchfopen #1{%
  1471. \chapoddpage {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1472. }
  1473.  
  1474. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1475. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1476. \par\penalty 5000 %
  1477. }
  1478.  
  1479. \def\CHAPFopen{
  1480. \global\let\chapmacro=\chfopen
  1481. \global\let\unnumbchapmacro=\unnchfopen}
  1482.  
  1483. % Parameter controlling skip before section headings.
  1484.  
  1485. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1486. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1487.  
  1488. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1489. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1490.  
  1491.  
  1492. % Section fonts are the base font at magstep2, which produces
  1493. % a size a bit more than 14 points in the default situation.    
  1494.  
  1495. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1496. \def\plainsecheading #1{\secheadingi {#1}}
  1497. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1498. \secheadingbreak}%
  1499. {\secfonts \line{\rm #1\hfill}}%
  1500. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1501.  
  1502.  
  1503. % Subsection fonts are the base font at magstep1, 
  1504. % which produces a size of 12 points.
  1505.  
  1506. \def\subsecheading #1#2#3#4{{\advance \subsecheadingskip by \parskip %
  1507. \subsecheadingbreak}%
  1508. {\subsecfonts \line{\rm#2.#3.#4\enspace #1\hfill}}%
  1509. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1510.  
  1511. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1512.                   % Perhaps make sssec fonts scaled
  1513.                   % magstep half
  1514. \def\subsubsecheading #1#2#3#4#5{{\advance \subsecheadingskip by \parskip %
  1515. \subsecheadingbreak}%
  1516. {\subsubsecfonts \line{\rm#2.#3.#4.#5\enspace #1\hfill}}%
  1517. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1518.  
  1519.  
  1520. \message{toc printing,}
  1521.  
  1522. % Finish up the main text and prepare to read what we've written
  1523. % to \contentsfile.
  1524.  
  1525. \def\startcontents#1{%
  1526.    \ifnum \pageno>0
  1527.       \pagealignmacro
  1528.       \immediate\closeout \contentsfile
  1529.       \pageno = -1        % Request roman numbered pages.
  1530.    \fi
  1531.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1532.    % It is abundantly clear what they are.
  1533.    \unnumbchapmacro{#1}\def\thischapter{}%
  1534.    \begingroup           % Set up to handle contents files properly.
  1535.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1536.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1537.       \advance\hsize by -1in    % Don't use the full line length.
  1538. }
  1539.  
  1540.   
  1541. % Normal (long) toc.
  1542. \outer\def\contents{%
  1543.    \startcontents{Table of Contents}%
  1544.       \input \jobname.toc
  1545.    \endgroup
  1546.    \vfill \eject
  1547. }
  1548.  
  1549. % And just the chapters.
  1550. \outer\def\summarycontents{%
  1551.    \startcontents{Short Contents}%
  1552.       %
  1553.       \let\chapentry = \shortchapentry
  1554.       \let\unnumbchapentry = \shortunnumberedentry
  1555.       % We want a true roman here for the page numbers.
  1556.       \secfonts \let\rm = \truesecrm \rm
  1557.       \advance\baselineskip by 1pt % Open it up a little.
  1558.       \def\secentry ##1##2##3##4{}
  1559.       \def\unnumbsecentry ##1##2{}
  1560.       \def\subsecentry ##1##2##3##4##5{}
  1561.       \def\unnumbsubsecentry ##1##2{}
  1562.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1563.       \def\unnumbsubsubsecentry ##1##2{}
  1564.       \input \jobname.toc
  1565.    \endgroup
  1566.    \vfill \eject
  1567. }
  1568. \let\shortcontents = \summarycontents
  1569.  
  1570. % These macros generate individual entries in the table of contents.
  1571. % The first argument is the chapter or section name.
  1572. % The last argument is the page number.
  1573. % The arguments in between are the chapter number, section number, ...
  1574.  
  1575. % Chapter-level things, for both the long and short contents.
  1576. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1577. \def\shortchapentry#1#2#3{%
  1578.    \line{{#2\labelspace #1}\dotfill\doshortpageno{#3}}%
  1579. }
  1580.  
  1581. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1582. \def\shortunnumberedentry#1#2{%
  1583.    \line{#1\dotfill\doshortpageno{#2}}%
  1584. }
  1585.  
  1586. % Sections.
  1587. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1588. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1589.  
  1590. % Subsections.
  1591. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1592. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1593.  
  1594. % And subsubsections.
  1595. \def\subsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1596. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1597.  
  1598.  
  1599. % This parameter controls the indentation of the various levels.
  1600. \newdimen\tocindent \tocindent = 3pc
  1601.  
  1602. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1603. % page number.
  1604. %
  1605. % If the toc has to be broken over pages, we would want to be at chapters 
  1606. % if at all possible; hence the \penalty.
  1607. \def\dochapentry#1#2{%
  1608.    \penalty-300 \vskip\baselineskip
  1609.    \line{\chapentryfonts #1\dotfill \dopageno{#2}}%
  1610.    \nobreak\vskip .25\baselineskip
  1611. }
  1612.  
  1613. \def\dosecentry#1#2{%
  1614.    \line{\secentryfonts \hskip\tocindent #1\dotfill \dopageno{#2}}%
  1615. }
  1616.  
  1617. \def\dosubsecentry#1#2{%
  1618.    \line{\subsecentryfonts \hskip2\tocindent #1\dotfill \dopageno{#2}}%
  1619. }
  1620.  
  1621. \def\dosubsubsecentry#1#2{%
  1622.    \line{\subsubsecentryfonts \hskip3\tocindent #1\dotfill \dopageno{#2}}%
  1623. }
  1624.  
  1625. % Space between chapter (or whatever) number and the title.
  1626. \def\labelspace{\hskip1em \relax}
  1627.  
  1628. \def\dopageno#1{{\rm #1}}
  1629. \def\doshortpageno#1{{\rm #1}}
  1630.  
  1631. \def\chapentryfonts{\secfonts \rm}
  1632. \def\secentryfonts{\textfonts}
  1633. \let\subsecentryfonts = \textfonts
  1634. \let\subsubsecentryfonts = \textfonts
  1635.  
  1636.  
  1637. \message{environments,}
  1638.  
  1639. % Since these characters are used in examples, it should be an even number of 
  1640. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1641. % Furthermore, these definitions must come after we define our fonts.
  1642. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1643. \newbox\pushcharbox    \newbox\bullbox
  1644. \newbox\equivbox       \newbox\errorbox
  1645.  
  1646. \let\ptexequiv = \equiv
  1647.  
  1648. {\tentt
  1649. \global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1650. \global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1651. \global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1652. \global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  1653. % Adapted from the manmac format (p.420 of TeXbook)
  1654. \global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  1655.                                       depth .1ex\hfil}
  1656. }
  1657.  
  1658. \def\point{$\star$}
  1659.  
  1660. \def\result{\leavevmode\raise.15ex\copy\dblarrowbox}
  1661. \def\expansion{\leavevmode\raise.1ex\copy\longdblarrowbox}
  1662. \def\print{\leavevmode\lower.1ex\copy\pushcharbox}
  1663.  
  1664. \def\equiv{\leavevmode\lower.1ex\copy\equivbox}
  1665.  
  1666. % Does anyone really want this?
  1667. % \def\bull{\leavevmode\copy\bullbox}
  1668.  
  1669. % Adapted from the TeXbook's \boxit.
  1670. {\tentt \global\dimen0 = 3em}% Width of the box.
  1671. \dimen2 = .55pt % Thickness of rules
  1672. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  1673. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  1674.  
  1675. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  1676.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  1677.    \advance\hsize by -2\dimen2 % Rules.
  1678.    \vbox{
  1679.       \hrule height\dimen2
  1680.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  1681.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  1682.          \kern3pt\vrule width\dimen2}% Space to right.
  1683.       \hrule height\dimen2}
  1684.     \hfil}
  1685.  
  1686. % The @error{} command.
  1687. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  1688.  
  1689. % @tex ... @end tex    escapes into raw Tex temporarily.
  1690. % One exception: @ is still an escape character, so that @end tex works.
  1691. % But \@ or @@ will get a plain tex @ character.
  1692.  
  1693. \def\tex{\begingroup
  1694. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  1695. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  1696. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  1697. \catcode `\%=14
  1698. \catcode`\"=12
  1699. \catcode`\==12
  1700. \catcode`\|=12
  1701. \catcode`\<=12
  1702. \catcode`\>=12
  1703. \escapechar=`\\
  1704. %
  1705. \let\{=\ptexlbrace
  1706. \let\}=\ptexrbrace
  1707. \let\.=\ptexdot
  1708. \let\*=\ptexstar
  1709. \def\@={@}%
  1710. \let\bullet=\ptexbullet
  1711. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  1712. \let\L=\ptexL
  1713. %
  1714. \let\Etex=\endgroup}
  1715.  
  1716. % Define @lisp ... @endlisp.
  1717. % @lisp does a \begingroup so it can rebind things,
  1718. % including the definition of @endlisp (which normally is erroneous).
  1719.  
  1720. % Amount to narrow the margins by for @lisp.
  1721. \newskip\lispnarrowing \lispnarrowing=0.4in
  1722.  
  1723. % This is the definition that ^M gets inside @lisp
  1724. % phr: changed space to \null, to avoid overfull hbox problems.
  1725. {\obeyspaces%
  1726. \gdef\lisppar{\null\endgraf}}
  1727.  
  1728. % Cause \obeyspaces to make each Space cause a word-separation
  1729. % rather than the default which is that it acts punctuation.
  1730. % This is because space in tt font looks funny.
  1731. {\obeyspaces %
  1732. \gdef\sepspaces{\def {\ }}}
  1733.  
  1734. \newskip\aboveenvskipamount \aboveenvskipamount= 0pt
  1735. \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
  1736. \endgraf \ifdim\lastskip<\aboveenvskipamount
  1737. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
  1738.  
  1739. \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
  1740. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
  1741.  
  1742. \def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
  1743. \hfuzz=12truept % Don't be fussy
  1744. % Make spaces be word-separators rather than space tokens.
  1745. \sepspaces %
  1746. % Single space lines
  1747. \singlespace %
  1748. % The following causes blank lines not to be ignored
  1749. % by adding a space to the end of each line.
  1750. \let\par=\lisppar
  1751. \def\Elisp{\endgroup\afterenvbreak}%
  1752. \parskip=0pt
  1753. \advance \leftskip by \lispnarrowing
  1754. \parindent=0pt
  1755. \let\exdent=\internalexdent
  1756. \obeyspaces \obeylines \tt \rawbackslash
  1757. \def\next##1{}\next}
  1758.  
  1759.  
  1760. \let\example=\lisp
  1761. \def\Eexample{\Elisp}
  1762.  
  1763. \let\smallexample=\lisp
  1764. \def\Esmallexample{\Elisp}
  1765.  
  1766. % Macro for 9 pt. examples, necessary to print with 5" lines.
  1767. % From Pavel@xerox.  This is not really used unless the
  1768. % @smallbook command is given.
  1769.  
  1770. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  1771. %            This group ends at the end of the @lisp body
  1772. \hfuzz=12truept % Don't be fussy
  1773. % Make spaces be word-separators rather than space tokens.
  1774. \sepspaces %
  1775. % Single space lines
  1776. \singlespace %
  1777. % The following causes blank lines not to be ignored
  1778. % by adding a space to the end of each line.
  1779. \let\par=\lisppar
  1780. \def\Esmalllisp{\endgroup\afterenvbreak}%
  1781. \parskip=0pt
  1782. \advance \leftskip by \lispnarrowing
  1783. \parindent=0pt
  1784. \let\exdent=\internalexdent
  1785. \obeyspaces \obeylines \ninett \rawbackslash
  1786. \def\next##1{}\next}
  1787.  
  1788. % This is @display; same as @lisp except use roman font.
  1789.  
  1790. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  1791. \aboveenvbreak
  1792. % Make spaces be word-separators rather than space tokens.
  1793. \sepspaces %
  1794. % Single space lines
  1795. \singlespace %
  1796. % The following causes blank lines not to be ignored
  1797. % by adding a space to the end of each line.
  1798. \let\par=\lisppar
  1799. \def\Edisplay{\endgroup\afterenvbreak}%
  1800. \parskip=0pt
  1801. \advance \leftskip by \lispnarrowing
  1802. \parindent=0pt
  1803. \let\exdent=\internalexdent
  1804. \obeyspaces \obeylines
  1805. \def\next##1{}\next}
  1806.  
  1807. % This is @format; same as @lisp except use roman font and don't narrow margins
  1808.  
  1809. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  1810. \aboveenvbreak
  1811. % Make spaces be word-separators rather than space tokens.
  1812. \sepspaces %
  1813. \singlespace %
  1814. % The following causes blank lines not to be ignored
  1815. % by adding a space to the end of each line.
  1816. \let\par=\lisppar
  1817. \def\Eformat{\endgroup\afterenvbreak}
  1818. \parskip=0pt \parindent=0pt
  1819. \obeyspaces \obeylines
  1820. \def\next##1{}\next}
  1821.  
  1822. % @flushleft and @flushright
  1823.  
  1824. \def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
  1825. \aboveenvbreak
  1826. % Make spaces be word-separators rather than space tokens.
  1827. \sepspaces %
  1828. % The following causes blank lines not to be ignored
  1829. % by adding a space to the end of each line.
  1830. % This also causes @ to work when the directive name
  1831. % is terminated by end of line.
  1832. \let\par=\lisppar
  1833. \def\Eflushleft{\endgroup\afterenvbreak}%
  1834. \parskip=0pt \parindent=0pt
  1835. \obeyspaces \obeylines
  1836. \def\next##1{}\next}
  1837.  
  1838. \def\flushright{\begingroup\inENV %This group ends at the end of the @format body
  1839. \aboveenvbreak
  1840. % Make spaces be word-separators rather than space tokens.
  1841. \sepspaces %
  1842. % The following causes blank lines not to be ignored
  1843. % by adding a space to the end of each line.
  1844. % This also causes @ to work when the directive name
  1845. % is terminated by end of line.
  1846. \let\par=\lisppar
  1847. \def\Eflushright{\endgroup\afterenvbreak}%
  1848. \parskip=0pt \parindent=0pt
  1849. \advance \leftskip by 0pt plus 1fill
  1850. \obeyspaces \obeylines
  1851. \def\next##1{}\next}
  1852.  
  1853. % @quotation - narrow the margins.
  1854.  
  1855. \def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
  1856. {\parskip=0pt  % because we will skip by \parskip too, later
  1857. \aboveenvbreak}%
  1858. \singlespace
  1859. \parindent=0pt
  1860. \def\Equotation{\par\endgroup\afterenvbreak}%
  1861. \advance \rightskip by \lispnarrowing 
  1862. \advance \leftskip by \lispnarrowing}
  1863.  
  1864. \message{defuns,}
  1865. % Define formatter for defuns
  1866. % First, allow user to change definition object font (\df) internally
  1867. \def\setdeffont #1 {\csname DEF#1\endcsname}
  1868.  
  1869. \newskip\defbodyindent \defbodyindent=.4in
  1870. \newskip\defargsindent \defargsindent=50pt
  1871. \newskip\deftypemargin \deftypemargin=12pt
  1872. \newskip\deflastargmargin \deflastargmargin=18pt
  1873.  
  1874. \newcount\parencount
  1875. % define \functionparens, which makes ( and ) and & do special things.
  1876. % \functionparens affects the group it is contained in.
  1877. \def\activeparens{%
  1878. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  1879. \catcode`\[=\active \catcode`\]=\active}
  1880. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  1881. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  1882. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  1883.  
  1884. % Definitions of (, ) and & used in args for functions.
  1885. % This is the definition of ( outside of all parentheses.
  1886. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  1887. \global\advance\parencount by 1 }
  1888. %
  1889. % This is the definition of ( when already inside a level of parens.
  1890. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  1891. %
  1892. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  1893. % also in that case restore the outer-level definition of (.
  1894. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  1895. \global\advance \parencount by -1 }
  1896. % If we encounter &foo, then turn on ()-hacking afterwards
  1897. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  1898. %
  1899. \gdef\normalparens{\boldbrax\let&=\ampnr}
  1900. } % End of definition inside \activeparens
  1901. %% These parens (in \boldbrax) actually are a little bolder than the
  1902. %% contained text.  This is especially needed for [ and ]
  1903. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  1904. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  1905.  
  1906. % First, defname, which formats the header line itself.
  1907. % #1 should be the function name.
  1908. % #2 should be the type of definition, such as "Function".
  1909.  
  1910. \def\defname #1#2{%
  1911. \leftskip = 0in  %
  1912. \noindent        %
  1913. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  1914. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  1915. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  1916. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  1917. % Now output arg 2 ("Function" or some such)
  1918. % ending at \deftypemargin from the right margin,
  1919. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  1920. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}%
  1921. \tolerance=10000 \hbadness=10000    % Make all lines underfull and no complaints
  1922. {\df #1}\enskip        % Generate function name
  1923. }
  1924.  
  1925. % Actually process the body of a definition
  1926. % #1 should be the terminating control sequence, such as \Edefun.
  1927. % #2 should be the "another name" control sequence, such as \defunx.
  1928. % #3 should be the control sequence that actually processes the header,
  1929. %    such as \defunheader.
  1930.  
  1931. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  1932. \medbreak %
  1933. % Define the end token that this defining construct specifies
  1934. % so that it will exit this group.
  1935. \def#1{\endgraf\endgroup\medbreak}%
  1936. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  1937. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1938. \begingroup %
  1939. \catcode 61=\active %
  1940. \obeylines\activeparens\spacesplit#3}
  1941.  
  1942. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  1943. \medbreak %
  1944. % Define the end token that this defining construct specifies
  1945. % so that it will exit this group.
  1946. \def#1{\endgraf\endgroup\medbreak}%
  1947. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  1948. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1949. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  1950.  
  1951. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  1952. \medbreak %
  1953. % Define the end token that this defining construct specifies
  1954. % so that it will exit this group.
  1955. \def#1{\endgraf\endgroup\medbreak}%
  1956. \def#2##1 ##2 {\def#4{##1}%
  1957. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  1958. \parindent=0in \leftskip=\defbodyindent %
  1959. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  1960.  
  1961. % Split up #2 at the first space token.
  1962. % call #1 with two arguments:
  1963. %  the first is all of #2 before the space token,
  1964. %  the second is all of #2 after that space token.
  1965. % If #2 contains no space token, all of it is passed as the first arg
  1966. % and the second is passed as empty.
  1967.  
  1968. {\obeylines
  1969. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  1970. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  1971. \ifx\relax #3%
  1972. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  1973.  
  1974. % So much for the things common to all kinds of definitions.
  1975.  
  1976. % Define @defun.
  1977.  
  1978. % First, define the processing that is wanted for arguments of \defun
  1979. % Use this to expand the args and terminate the paragraph they make up
  1980.  
  1981. \def\defunargs #1{\functionparens \sl
  1982. % Expand, preventing hyphenation at `-' chars.
  1983. % Note that groups don't affect changes in \hyphenchar.
  1984. \hyphenchar\sl=0
  1985. #1%
  1986. \hyphenchar\sl=45
  1987. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  1988. \interlinepenalty=10000
  1989. \advance\rightskip by 0pt plus 1fil
  1990. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  1991. }
  1992.  
  1993. % Do complete processing of one @defun or @defunx line already parsed.
  1994.  
  1995. % @deffn Command forward-char nchars
  1996.  
  1997. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  1998.  
  1999. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2000. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2001. \catcode 61=\other % Turn off change made in \defparsebody
  2002. }
  2003.  
  2004. % @defun == @deffn Function
  2005.  
  2006. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2007.  
  2008. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2009. \begingroup\defname {#1}{Function}%
  2010. \defunargs {#2}\endgroup %
  2011. \catcode 61=\other % Turn off change made in \defparsebody
  2012. }
  2013.  
  2014. % @defmac == @deffn Macro
  2015.  
  2016. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2017.  
  2018. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2019. \begingroup\defname {#1}{Macro}%
  2020. \defunargs {#2}\endgroup %
  2021. \catcode 61=\other % Turn off change made in \defparsebody
  2022. }
  2023.  
  2024. % @defspec == @deffn Special Form
  2025.  
  2026. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2027.  
  2028. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2029. \begingroup\defname {#1}{Special form}%
  2030. \defunargs {#2}\endgroup %
  2031. \catcode 61=\other % Turn off change made in \defparsebody
  2032. }
  2033.  
  2034. % This definition is run if you use @defunx
  2035. % anywhere other than immediately after a @defun or @defunx.
  2036.  
  2037. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2038. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2039. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2040. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2041.  
  2042. % @defmethod, and so on
  2043.  
  2044. % @defop {Funny Method} foo-class frobnicate argument
  2045.  
  2046. \def\defop #1 {\def\defoptype{#1}%
  2047. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2048.  
  2049. \def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2050. \begingroup\defname {#2}{\defoptype{} on #1}%
  2051. \defunargs {#3}\endgroup %
  2052. }
  2053.  
  2054. % @defmethod == @defop Method
  2055.  
  2056. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2057.  
  2058. \def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2059. \begingroup\defname {#2}{Operation on #1}%
  2060. \defunargs {#3}\endgroup %
  2061. }
  2062.  
  2063. % @defcv {Class Option} foo-class foo-flag
  2064.  
  2065. \def\defcv #1 {\def\defcvtype{#1}%
  2066. \defopparsebody\Edefcv\defcvx\defcvheader\defcvtype}
  2067.  
  2068. \def\defcvarheader #1#2#3{%
  2069. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2070. \begingroup\defname {#2}{\defcvtype of #1}%
  2071. \defvarargs {#3}\endgroup %
  2072. }
  2073.  
  2074. % @defivar == @defcv {Instance Variable}
  2075.  
  2076. \def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
  2077.  
  2078. \def\defivarheader #1#2#3{%
  2079. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2080. \begingroup\defname {#2}{Instance variable of #1}%
  2081. \defvarargs {#3}\endgroup %
  2082. }
  2083.  
  2084. % These definitions are run if you use @defmethodx, etc.,
  2085. % anywhere other than immediately after a @defmethod, etc.
  2086.  
  2087. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2088. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2089. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2090. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2091.  
  2092. % Now @defvar
  2093.  
  2094. % First, define the processing that is wanted for arguments of @defvar.
  2095. % This is actually simple: just print them in roman.
  2096. % This must expand the args and terminate the paragraph they make up
  2097. \def\defvarargs #1{\normalparens #1%
  2098. \interlinepenalty=10000
  2099. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2100.  
  2101. % @defvr Counter foo-count
  2102.  
  2103. \def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
  2104.  
  2105. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2106. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2107.  
  2108. % @defvar == @defvr Variable
  2109.  
  2110. \def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
  2111.  
  2112. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2113. \begingroup\defname {#1}{Variable}%
  2114. \defvarargs {#2}\endgroup %
  2115. }
  2116.  
  2117. % @defopt == @defvr {User Option}
  2118.  
  2119. \def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
  2120.  
  2121. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2122. \begingroup\defname {#1}{User Option}%
  2123. \defvarargs {#2}\endgroup %
  2124. }
  2125.  
  2126. % This definition is run if you use @defvarx
  2127. % anywhere other than immediately after a @defvar or @defvarx.
  2128.  
  2129. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2130. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2131. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2132.  
  2133. % Now define @deftp
  2134. % Args are printed in bold, a slight difference from @defvar.
  2135.  
  2136. \def\deftpargs #1{\bf \defvarargs{#1}}
  2137.  
  2138. % @deftp Class window height width ...
  2139.  
  2140. \def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
  2141.  
  2142. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2143. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2144.  
  2145. % This definition is run if you use @deftpx, etc
  2146. % anywhere other than immediately after a @deftp, etc.
  2147.  
  2148. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2149.  
  2150. \message{cross reference,}
  2151. % Define cross-reference macros
  2152. \newwrite \auxfile
  2153.  
  2154. \newif\ifhavexrefs  % True if xref values are known.
  2155. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2156.  
  2157. % \setref{foo} defines a cross-reference point named foo.
  2158.  
  2159. \def\setref#1{%
  2160. \dosetq{#1-pg}{Ypagenumber}%
  2161. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2162.  
  2163. \def\unnumbsetref#1{%
  2164. \dosetq{#1-pg}{Ypagenumber}%
  2165. \dosetq{#1-snt}{Ynothing}}
  2166.  
  2167. \def\appendixsetref#1{%
  2168. \dosetq{#1-pg}{Ypagenumber}%
  2169. \dosetq{#1-snt}{Yappendixletterandtype}}
  2170.  
  2171. % \xref and \pxref generate cross references to specified points.
  2172.  
  2173. \def\pxref #1{see \xrefX [#1,,,,,,,]}
  2174. \def\xref #1{See \xrefX [#1,,,,,,,]}
  2175. \def\ref #1{\xrefX [#1,,,,,,,]}
  2176. \def\xrefX [#1,#2,#3,#4,#5,#6]{%
  2177. \setbox1=\hbox{\i{\losespace#5{}}}%
  2178. \setbox0=\hbox{\losespace#3{}}%
  2179. \ifdim \wd0 =0pt \setbox0=\hbox{\losespace#1{}}\fi%
  2180. \ifdim \wd1 >0pt%
  2181. section `\unhbox0' in \unhbox1%
  2182. \else%
  2183. \refx{#1-snt}{} [\unhbox0], page\tie \refx{#1-pg}{}%
  2184. \fi }
  2185.  
  2186. % \dosetq is the interface for calls from other macros
  2187.  
  2188. \def\dosetq #1#2{{\let\folio=0%
  2189. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2190. \next}}
  2191.  
  2192. % \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2193. % When the aux file is read, ' is the escape character
  2194.  
  2195. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2196.  
  2197. % Things to be expanded by \internalsetq
  2198.  
  2199. \def\Ypagenumber{\folio}
  2200.  
  2201. \def\Ynothing{}
  2202.  
  2203. \def\Ysectionnumberandtype{%
  2204. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2205. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2206. \else \ifnum \subsubsecno=0 %
  2207. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2208. \else %
  2209. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2210. \fi \fi \fi }
  2211.  
  2212. \def\Yappendixletterandtype{%
  2213. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno %
  2214. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2215. \else \ifnum \subsubsecno=0 %
  2216. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2217. \else %
  2218. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2219. \fi \fi \fi }
  2220.  
  2221. \gdef\xreftie{'tie}
  2222.  
  2223. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2224. % If its value is nonempty, SUFFIX is output afterward.
  2225.  
  2226. \def\refx#1#2{%
  2227. {%
  2228. \expandafter\ifx\csname X#1\endcsname\relax
  2229. % If not defined, say something at least.
  2230. {$\langle$un\-def\-in\-ed$\rangle$}#2%
  2231. \ifhavexrefs
  2232. \message {WARNING: undefined cross-reference "#1"}%
  2233. \message {}%
  2234. \else
  2235. \ifwarnedxrefs
  2236. \else
  2237. \global\warnedxrefstrue
  2238. \message {WARNING: cross-references values are not known; you must run TeX a second time}%
  2239. \message {}%
  2240. \fi
  2241. \fi
  2242. \fi
  2243. \setbox0=\hbox{\csname X#1\endcsname}%It's defined, so just use it.
  2244. \ifdim\wd0>0pt \unhbox0{}#2\fi
  2245. }}
  2246.  
  2247. % Read the last existing aux file, if any.  No error if none exists.
  2248.  
  2249. % This is the macro invoked by entries in the aux file.
  2250. \def\xrdef #1#2{
  2251. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2252.  
  2253. \def\readauxfile{%
  2254. \begingroup
  2255. \catcode `\^^@=\other
  2256. \catcode `\^^A=\other
  2257. \catcode `\^^B=\other
  2258. \catcode `\^^C=\other
  2259. \catcode `\^^D=\other
  2260. \catcode `\^^E=\other
  2261. \catcode `\^^F=\other
  2262. \catcode `\^^G=\other
  2263. \catcode `\^^H=\other
  2264. \catcode `\^^K=\other
  2265. \catcode `\^^L=\other
  2266. \catcode `\^^N=\other
  2267. \catcode `\^^O=\other
  2268. \catcode `\^^P=\other
  2269. \catcode `\^^Q=\other
  2270. \catcode `\^^R=\other
  2271. \catcode `\^^S=\other
  2272. \catcode `\^^T=\other
  2273. \catcode `\^^U=\other
  2274. \catcode `\^^V=\other
  2275. \catcode `\^^W=\other
  2276. \catcode `\^^X=\other
  2277. \catcode `\^^Y=\other
  2278. \catcode `\^^Z=\other
  2279. \catcode `\^^[=\other
  2280. \catcode `\^^\=\other
  2281. \catcode `\^^]=\other
  2282. \catcode `\^^^=\other
  2283. \catcode `\^^_=\other
  2284. \catcode `\@=\other
  2285. \catcode `\^=\other
  2286. \catcode `\~=\other
  2287. \catcode `\[=\other
  2288. \catcode `\]=\other
  2289. \catcode`\"=\other
  2290. \catcode`\_=\other
  2291. \catcode`\|=\other
  2292. \catcode`\<=\other
  2293. \catcode`\>=\other
  2294. \catcode `\$=\other
  2295. \catcode `\#=\other
  2296. \catcode `\&=\other
  2297. % the aux file uses ' as the escape.
  2298. % Turn off \ as an escape so we do not lose on
  2299. % entries which were dumped with control sequences in their names.
  2300. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2301. % Reference to such entries still does not work the way one would wish,
  2302. % but at least they do not bomb out when the aux file is read in.
  2303. \catcode `\{=1 \catcode `\}=2
  2304. \catcode `\%=\other
  2305. \catcode `\'=0
  2306. \catcode `\\=\other
  2307. \openin 1 \jobname.aux
  2308. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2309. \fi
  2310. % Open the new aux file.  Tex will close it automatically at exit.
  2311. \openout \auxfile=\jobname.aux
  2312. \endgroup}
  2313.  
  2314.  
  2315. % Footnotes.
  2316.  
  2317. \newcount \footnoteno
  2318.  
  2319. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2320.  
  2321. \let\ptexfootnote=\footnote
  2322.  
  2323. {\catcode `\@=11
  2324. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2325. \edef\thisfootno{$^{\the\footnoteno}$}%
  2326. \let\@sf\empty
  2327. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2328. \thisfootno\@sf \footnotezzz{#1}}
  2329. % \parsearg\footnotezzz}
  2330.  
  2331. \long\gdef\footnotezzz #1{\insert\footins{
  2332. \interlinepenalty\interfootnotelinepenalty
  2333. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2334. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2335. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2336. \footstrut\hang\textindent{\thisfootno}#1\strut}}
  2337.  
  2338. }%end \catcode `\@=11
  2339.  
  2340. % End of control word definitions.
  2341.  
  2342. \message{and turning on texinfo input format.}
  2343.  
  2344. \def\openindices{%
  2345.    \newindex{cp}%
  2346.    \newcodeindex{fn}%
  2347.    \newcodeindex{vr}%
  2348.    \newcodeindex{tp}%
  2349.    \newcodeindex{ky}%
  2350.    \newcodeindex{pg}%
  2351. }
  2352.  
  2353. % Set some numeric style parameters, for 8.5 x 11 format.
  2354.  
  2355. %\hsize = 6.5in
  2356. \parindent 15pt
  2357. \parskip 18pt plus 1pt
  2358. \baselineskip 15pt
  2359. \advance\topskip by 1.2cm
  2360.  
  2361. % Prevent underfull vbox error messages.
  2362. \vbadness=10000
  2363.  
  2364. % Use @smallbook to reset parameters for 7x9.5 format
  2365. \def\smallbook{
  2366. \global\lispnarrowing = 0.3in
  2367. \global\baselineskip 12pt
  2368. \global\parskip 3pt plus 1pt
  2369. \global\hsize = 5in
  2370. \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
  2371. \global\vsize=7.5in
  2372. \global\tolerance=700
  2373. \global\hfuzz=1pt
  2374.  
  2375. \global\pagewidth=\hsize
  2376. \global\pageheight=\vsize
  2377.  
  2378. \global\let\smalllisp=\smalllispx
  2379. \global\let\smallexample=\smalllispx
  2380. \global\def\Esmallexample{\Esmalllisp}
  2381. }
  2382.  
  2383. %% For a final copy, take out the rectangles
  2384. %% that mark overfull boxes (in case you have decided
  2385. %% that the text looks ok even though it passes the margin).
  2386. \def\finalout{\overfullrule=0pt}
  2387.  
  2388. % Turn off all special characters except @
  2389. % (and those which the user can use as if they were ordinary)
  2390. % Define certain chars to be always in tt font.
  2391.  
  2392. \catcode`\"=\active
  2393. \def\activedoublequote{{\tt \char '042}}
  2394. \let"=\activedoublequote
  2395. \catcode`\~=\active
  2396. \def~{{\tt \char '176}}
  2397. \chardef\hat=`\^
  2398. \catcode`\^=\active
  2399. \def^{{\tt \hat}}
  2400. \catcode`\_=\active
  2401. \def_{{\tt \char '137}}
  2402. \catcode`\|=\active
  2403. \def|{{\tt \char '174}}
  2404. \chardef \less=`\<
  2405. \catcode`\<=\active
  2406. \def<{{\tt \less}}
  2407. \chardef \gtr=`\>
  2408. \catcode`\>=\active
  2409. \def>{{\tt \gtr}}
  2410. \catcode`\+=\active
  2411. \def+{{\tt \char 43}}
  2412. %\catcode 27=\active
  2413. %\def^^[{$\diamondsuit$}
  2414.  
  2415. % Set up an active definition for =, but don't enable it most of the time.
  2416. {\catcode`\==\active
  2417. \global\def={{\tt \char 61}}}
  2418.  
  2419. \catcode`\@=0
  2420.  
  2421. % \rawbackslashxx output one backslash character in current font
  2422. \global\chardef\rawbackslashxx=`\\
  2423. %{\catcode`\\=\other
  2424. %@gdef@rawbackslashxx{\}}
  2425.  
  2426. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2427. {\catcode`\\=\active
  2428. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  2429.  
  2430. % \normalbackslash outputs one backslash in fixed width font.
  2431. \def\normalbackslash{{\tt\rawbackslashxx}}
  2432.  
  2433. % Say @foo, not \foo, in error messages.
  2434. \escapechar=`\@
  2435.  
  2436. @c \catcode 17=0   @c Define control-q
  2437. \catcode`\\=\active
  2438.  
  2439. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  2440. % That is what \eatinput is for; after that, the `\' should revert to printing 
  2441. % a backslash.
  2442. %
  2443. @gdef@eatinput input texinfo{@fixbackslash}
  2444. @global@let\ = @eatinput
  2445.  
  2446. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  2447. % the first `\{ in the file would cause an error. This macro tries to fix 
  2448. % that, assuming it is called before the first `\' could plausibly occur.
  2449. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  2450.  
  2451. %% These look ok in all fonts, so just make them not special.  The @rm below
  2452. %% makes sure that the current font starts out as the newly loaded cmr10
  2453. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  2454.  
  2455. @textfonts
  2456. @rm
  2457.